aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReece R. Pollack2015-02-24 12:52:51 -0600
committerReece R. Pollack2015-02-24 12:52:51 -0600
commita17b4c3fd6c93f908daf032786f90c0321296957 (patch)
tree705c86318a2d0345d3067ddbd2f9d4539ed3d5cc
parentb918ff9e61cd10f5e44c0536d638b900a697f471 (diff)
parent639ea778eadd4f5b0a85acac872f50085826d511 (diff)
downloadlinux-v3.10.61/master.tar.gz
linux-v3.10.61/master.tar.xz
linux-v3.10.61/master.zip
Merge branch 'master/rebuild/24-drivers-net' into master/masterK2_LINUX_03.10.61_15.02v3.10.61/master
-rw-r--r--drivers/net/ethernet/ti/keystone_qos.c127
1 files changed, 1 insertions, 126 deletions
diff --git a/drivers/net/ethernet/ti/keystone_qos.c b/drivers/net/ethernet/ti/keystone_qos.c
index 2a3726cd77e..18366346865 100644
--- a/drivers/net/ethernet/ti/keystone_qos.c
+++ b/drivers/net/ethernet/ti/keystone_qos.c
@@ -41,7 +41,6 @@ struct qos_channel {
41 const char *tx_chan_name; 41 const char *tx_chan_name;
42 u32 tx_queue_depth; 42 u32 tx_queue_depth;
43 struct netcp_tx_pipe tx_pipe; 43 struct netcp_tx_pipe tx_pipe;
44 struct kobject kobj;
45}; 44};
46 45
47struct qos_device { 46struct qos_device {
@@ -49,104 +48,16 @@ struct qos_device {
49 struct device *dev; 48 struct device *dev;
50 struct device_node *node; 49 struct device_node *node;
51 u32 multi_if; 50 u32 multi_if;
52 struct kobject kobj;
53}; 51};
54 52
55struct qos_intf { 53struct qos_intf {
56 struct qos_device *qdev;
57 struct net_device *ndev; 54 struct net_device *ndev;
58 struct device *dev; 55 struct device *dev;
59 struct kobject kobj;
60 int num_channels; 56 int num_channels;
61 int max_channels; 57 int max_channels;
62 struct qos_channel channels[1]; 58 struct qos_channel channels[1];
63 /* NB: channels is allocated dynamically */
64}; 59};
65 60
66/*
67 * Sysfs stuff related to QoS TX Channels
68 */
69#define kobj_to_qchan(kobj) container_of(kobj, struct qos_channel, kobj)
70
71static ssize_t qos_txchan_show(struct kobject *kobj,
72 struct kobj_attribute *attr,
73 char *buf)
74{
75 struct qos_channel *qos_chan = kobj_to_qchan(kobj);
76 return snprintf(buf, PAGE_SIZE, "%s\n", qos_chan->tx_chan_name);
77}
78
79struct kobj_attribute qos_txchan_attr =
80 __ATTR(tx-channel, S_IRUGO, qos_txchan_show, NULL);
81
82
83static ssize_t qos_txdepth_show(struct kobject *kobj,
84 struct kobj_attribute *attr,
85 char *buf)
86{
87 struct qos_channel *qos_chan = kobj_to_qchan(kobj);
88 return snprintf(buf, PAGE_SIZE, "%u\n", qos_chan->tx_queue_depth);
89}
90
91static ssize_t qos_txdepth_store(struct kobject *kobj,
92 struct kobj_attribute *attr,
93 const char *buf, size_t count)
94{
95 struct qos_channel *qos_chan = kobj_to_qchan(kobj);
96 unsigned int val;
97
98 if (kstrtouint(buf, 0, &val) < 0)
99 return -EINVAL;
100
101 qos_chan->tx_queue_depth = val;
102
103 return count;
104}
105
106struct kobj_attribute qos_txdepth_attr =
107 __ATTR(tx_queue_depth, S_IRUGO | S_IWUSR,
108 qos_txdepth_show, qos_txdepth_store);
109
110static struct attribute *qos_txchan_attrs[] = {
111 &qos_txchan_attr.attr,
112 &qos_txdepth_attr.attr,
113 NULL
114};
115
116static struct kobj_type qos_chan_ktype = {
117 .sysfs_ops = &kobj_sysfs_ops,
118 .default_attrs = qos_txchan_attrs,
119};
120
121/* Sysfs stuff related to QoS Interfaces */
122static struct kobj_type qos_intf_ktype = {
123 .sysfs_ops = &kobj_sysfs_ops,
124};
125
126/* Sysfs stuff related to QoS Instances */
127#define kobj_to_qdev(kobj) container_of(kobj, struct qos_device, kobj)
128static ssize_t qos_multi_if_show(struct kobject *kobj,
129 struct kobj_attribute *attr,
130 char *buf)
131{
132 struct qos_device *qos_dev = kobj_to_qdev(kobj);
133 return snprintf(buf, PAGE_SIZE, "%u\n", qos_dev->multi_if);
134}
135
136struct kobj_attribute qos_multi_if_attr =
137 __ATTR(multi-interface, S_IRUGO, qos_multi_if_show, NULL);
138
139static struct attribute *qos_inst_attrs[] = {
140 &qos_multi_if_attr.attr,
141 NULL
142};
143
144static struct kobj_type qos_inst_ktype = {
145 .sysfs_ops = &kobj_sysfs_ops,
146 .default_attrs = qos_inst_attrs,
147};
148
149
150static int qos_tx_hook(int order, void *data, struct netcp_packet *p_info) 61static int qos_tx_hook(int order, void *data, struct netcp_packet *p_info)
151{ 62{
152 struct qos_intf *qos_intf = data; 63 struct qos_intf *qos_intf = data;
@@ -237,19 +148,6 @@ static int init_channel(struct qos_intf *qos_intf,
237 } 148 }
238 dev_dbg(qos_intf->dev, "tx_queue_depth %u\n", qchan->tx_queue_depth); 149 dev_dbg(qos_intf->dev, "tx_queue_depth %u\n", qchan->tx_queue_depth);
239 150
240 /* Create the per-channel entry and attributes */
241 ret = kobject_init_and_add(&qchan->kobj, &qos_chan_ktype,
242 kobject_get(&qos_intf->kobj), node->name);
243 if (ret) {
244 dev_err(qos_intf->dev,
245 "failed to create %s/%s/%s sysfs entry\n",
246 qos_intf->qdev->kobj.name, qos_intf->kobj.name,
247 node->name);
248 kobject_put(&qchan->kobj);
249 kobject_put(&qos_intf->kobj);
250 return ret;
251 }
252
253 return 0; 151 return 0;
254} 152}
255 153
@@ -275,7 +173,6 @@ static int qos_attach(void *inst_priv, struct net_device *ndev,
275 } 173 }
276 qos_intf->max_channels = max_channels; 174 qos_intf->max_channels = max_channels;
277 175
278 qos_intf->qdev = qos_dev;
279 qos_intf->ndev = ndev; 176 qos_intf->ndev = ndev;
280 qos_intf->dev = qos_dev->dev; 177 qos_intf->dev = qos_dev->dev;
281 178
@@ -293,17 +190,6 @@ static int qos_attach(void *inst_priv, struct net_device *ndev,
293 goto exit; 190 goto exit;
294 } 191 }
295 192
296 /* Create the per-interface sysfs entry */
297 ret = kobject_init_and_add(&qos_intf->kobj, &qos_intf_ktype,
298 kobject_get(&qos_intf->qdev->kobj), node_name);
299 if (ret) {
300 dev_err(qos_intf->dev, "failed to create %s/%s sysfs entry\n",
301 qos_intf->qdev->kobj.name, node_name);
302 kobject_put(&qos_intf->kobj);
303 kobject_put(&qos_intf->qdev->kobj);
304 goto exit;
305 }
306
307 qos_intf->num_channels = 0; 193 qos_intf->num_channels = 0;
308 for_each_child_of_node(interface, channel) { 194 for_each_child_of_node(interface, channel) {
309 if (qos_intf->num_channels >= max_channels) { 195 if (qos_intf->num_channels >= max_channels) {
@@ -359,7 +245,7 @@ static int qos_probe(struct netcp_device *netcp_device,
359{ 245{
360 struct qos_device *qos_dev; 246 struct qos_device *qos_dev;
361 int ret = 0; 247 int ret = 0;
362 248
363 qos_dev = devm_kzalloc(dev, sizeof(struct qos_device), GFP_KERNEL); 249 qos_dev = devm_kzalloc(dev, sizeof(struct qos_device), GFP_KERNEL);
364 if (!qos_dev) { 250 if (!qos_dev) {
365 dev_err(dev, "memory allocation failed\n"); 251 dev_err(dev, "memory allocation failed\n");
@@ -380,17 +266,6 @@ static int qos_probe(struct netcp_device *netcp_device,
380 if (of_find_property(node, "multi-interface", NULL)) 266 if (of_find_property(node, "multi-interface", NULL))
381 qos_dev->multi_if = 1; 267 qos_dev->multi_if = 1;
382 268
383 /* Create the per-instance sysfs entry */
384 ret = kobject_init_and_add(&qos_dev->kobj, &qos_inst_ktype,
385 kobject_get(&dev->kobj), node->name);
386 if (ret) {
387 dev_err(dev, "failed to create %s sysfs entry\n",
388 node->name);
389 kobject_put(&qos_dev->kobj);
390 kobject_put(&dev->kobj);
391 goto exit;
392 }
393
394 return 0; 269 return 0;
395 270
396exit: 271exit: