Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gianfar: Remove sysfs stubs for FIFOCFG and stashing

Removing the sysfs stubs for the Tx FIFOCFG and ATTRELI
(stashing) config registers, as these registers may only
be configured after a MAC reset, with the controller stopped
(i.e. during hw init, at probe() time). The current sysfs
stubs allow on-the-fly updates of these registers (the locking
measures are useless and only add unecessary code).

Changing these registers is discouraged. Only the default values
will be used instead.

Moreover, the stashing (ATTRELI) configuration options were
effectively disabled (didn't get to the hw anyway if changed)
because the stashing device_flags (HAS_BD_STASHING|HAS_BUF_STASHING)
were "accidentally" cleared during probe().

Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Claudiu Manoil and committed by
David S. Miller
34018fd4 20862788

+28 -408
-30
Documentation/networking/gianfar.txt
··· 1 1 The Gianfar Ethernet Driver 2 - Sysfs File description 3 2 4 3 Author: Andy Fleming <afleming@freescale.com> 5 4 Updated: 2005-07-28 6 5 7 - SYSFS 8 - 9 - Several of the features of the gianfar driver are controlled 10 - through sysfs files. These are: 11 - 12 - bd_stash: 13 - To stash RX Buffer Descriptors in the L2, echo 'on' or '1' to 14 - bd_stash, echo 'off' or '0' to disable 15 - 16 - rx_stash_len: 17 - To stash the first n bytes of the packet in L2, echo the number 18 - of bytes to buf_stash_len. echo 0 to disable. 19 - 20 - WARNING: You could really screw these up if you set them too low or high! 21 - fifo_threshold: 22 - To change the number of bytes the controller needs in the 23 - fifo before it starts transmission, echo the number of bytes to 24 - fifo_thresh. Range should be 0-511. 25 - 26 - fifo_starve: 27 - When the FIFO has less than this many bytes during a transmit, it 28 - enters starve mode, and increases the priority of TX memory 29 - transactions. To change, echo the number of bytes to 30 - fifo_starve. Range should be 0-511. 31 - 32 - fifo_starve_off: 33 - Once in starve mode, the FIFO remains there until it has this 34 - many bytes. To change, echo the number of bytes to 35 - fifo_starve_off. Range should be 0-511. 36 6 37 7 CHECKSUM OFFLOADING 38 8
+1 -2
drivers/net/ethernet/freescale/Makefile
··· 14 14 obj-$(CONFIG_GIANFAR) += gianfar_driver.o 15 15 obj-$(CONFIG_PTP_1588_CLOCK_GIANFAR) += gianfar_ptp.o 16 16 gianfar_driver-objs := gianfar.o \ 17 - gianfar_ethtool.o \ 18 - gianfar_sysfs.o 17 + gianfar_ethtool.o 19 18 obj-$(CONFIG_UCC_GETH) += ucc_geth_driver.o 20 19 ucc_geth_driver-objs := ucc_geth.o ucc_geth_ethtool.o
+27 -30
drivers/net/ethernet/freescale/gianfar.c
··· 338 338 struct gfar __iomem *regs = priv->gfargrp[0].regs; 339 339 u32 rctrl = 0; 340 340 u32 tctrl = 0; 341 - u32 attrs = 0; 342 341 343 342 /* write the tx/rx base registers */ 344 343 gfar_init_tx_rx_base(priv); ··· 408 409 } 409 410 410 411 gfar_write(&regs->tctrl, tctrl); 411 - 412 - /* Set the extraction length and index */ 413 - attrs = ATTRELI_EL(priv->rx_stash_size) | 414 - ATTRELI_EI(priv->rx_stash_index); 415 - 416 - gfar_write(&regs->attreli, attrs); 417 - 418 - /* Start with defaults, and add stashing or locking 419 - * depending on the approprate variables 420 - */ 421 - attrs = ATTR_INIT_SETTINGS; 422 - 423 - if (priv->bd_stash_en) 424 - attrs |= ATTR_BDSTASH; 425 - 426 - if (priv->rx_stash_size != 0) 427 - attrs |= ATTR_BUFSTASH; 428 - 429 - gfar_write(&regs->attr, attrs); 430 - 431 - gfar_write(&regs->fifo_tx_thr, priv->fifo_threshold); 432 - gfar_write(&regs->fifo_tx_starve, priv->fifo_starve); 433 - gfar_write(&regs->fifo_tx_starve_shutoff, priv->fifo_starve_off); 434 412 } 435 413 436 414 static struct net_device_stats *gfar_get_stats(struct net_device *dev) ··· 760 784 memcpy(dev->dev_addr, mac_addr, ETH_ALEN); 761 785 762 786 if (model && !strcasecmp(model, "TSEC")) 763 - priv->device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT | 787 + priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT | 764 788 FSL_GIANFAR_DEV_HAS_COALESCE | 765 789 FSL_GIANFAR_DEV_HAS_RMON | 766 790 FSL_GIANFAR_DEV_HAS_MULTI_INTR; 767 791 768 792 if (model && !strcasecmp(model, "eTSEC")) 769 - priv->device_flags = FSL_GIANFAR_DEV_HAS_GIGABIT | 793 + priv->device_flags |= FSL_GIANFAR_DEV_HAS_GIGABIT | 770 794 FSL_GIANFAR_DEV_HAS_COALESCE | 771 795 FSL_GIANFAR_DEV_HAS_RMON | 772 796 FSL_GIANFAR_DEV_HAS_MULTI_INTR | ··· 1006 1030 static void gfar_hw_init(struct gfar_private *priv) 1007 1031 { 1008 1032 struct gfar __iomem *regs = priv->gfargrp[0].regs; 1009 - u32 tempval; 1033 + u32 tempval, attrs; 1010 1034 1011 1035 /* Reset MAC layer */ 1012 1036 gfar_write(&regs->maccfg1, MACCFG1_SOFT_RESET); ··· 1027 1051 1028 1052 /* Initialize ECNTRL */ 1029 1053 gfar_write(&regs->ecntrl, ECNTRL_INIT_SETTINGS); 1054 + 1055 + /* Set the extraction length and index */ 1056 + attrs = ATTRELI_EL(priv->rx_stash_size) | 1057 + ATTRELI_EI(priv->rx_stash_index); 1058 + 1059 + gfar_write(&regs->attreli, attrs); 1060 + 1061 + /* Start with defaults, and add stashing 1062 + * depending on driver parameters 1063 + */ 1064 + attrs = ATTR_INIT_SETTINGS; 1065 + 1066 + if (priv->bd_stash_en) 1067 + attrs |= ATTR_BDSTASH; 1068 + 1069 + if (priv->rx_stash_size != 0) 1070 + attrs |= ATTR_BUFSTASH; 1071 + 1072 + gfar_write(&regs->attr, attrs); 1073 + 1074 + /* FIFO configs */ 1075 + gfar_write(&regs->fifo_tx_thr, DEFAULT_FIFO_TX_THR); 1076 + gfar_write(&regs->fifo_tx_starve, DEFAULT_FIFO_TX_STARVE); 1077 + gfar_write(&regs->fifo_tx_starve_shutoff, DEFAULT_FIFO_TX_STARVE_OFF); 1030 1078 1031 1079 /* Program the interrupt steering regs, only for MG devices */ 1032 1080 if (priv->num_grps > 1) ··· 1231 1231 1232 1232 /* Initialize the filer table */ 1233 1233 gfar_init_filer_table(priv); 1234 - 1235 - /* Create all the sysfs files */ 1236 - gfar_init_sysfs(dev); 1237 1234 1238 1235 /* Print out the device info */ 1239 1236 netdev_info(dev, "mac: %pM\n", dev->dev_addr);
-6
drivers/net/ethernet/freescale/gianfar.h
··· 1130 1130 u32 __iomem *hash_regs[16]; 1131 1131 int hash_width; 1132 1132 1133 - /* global parameters */ 1134 - unsigned int fifo_threshold; 1135 - unsigned int fifo_starve; 1136 - unsigned int fifo_starve_off; 1137 - 1138 1133 /*Filer table*/ 1139 1134 unsigned int ftp_rqfpr[MAX_FILER_IDX + 1]; 1140 1135 unsigned int ftp_rqfcr[MAX_FILER_IDX + 1]; ··· 1210 1215 void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, int enable, 1211 1216 u32 regnum, u32 read); 1212 1217 void gfar_configure_coalescing_all(struct gfar_private *priv); 1213 - void gfar_init_sysfs(struct net_device *dev); 1214 1218 int gfar_set_features(struct net_device *dev, netdev_features_t features); 1215 1219 void gfar_check_rx_parser_mode(struct gfar_private *priv); 1216 1220 void gfar_vlan_mode(struct net_device *dev, netdev_features_t features);
-340
drivers/net/ethernet/freescale/gianfar_sysfs.c
··· 1 - /* 2 - * drivers/net/ethernet/freescale/gianfar_sysfs.c 3 - * 4 - * Gianfar Ethernet Driver 5 - * This driver is designed for the non-CPM ethernet controllers 6 - * on the 85xx and 83xx family of integrated processors 7 - * Based on 8260_io/fcc_enet.c 8 - * 9 - * Author: Andy Fleming 10 - * Maintainer: Kumar Gala (galak@kernel.crashing.org) 11 - * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> 12 - * 13 - * Copyright 2002-2009 Freescale Semiconductor, Inc. 14 - * 15 - * This program is free software; you can redistribute it and/or modify it 16 - * under the terms of the GNU General Public License as published by the 17 - * Free Software Foundation; either version 2 of the License, or (at your 18 - * option) any later version. 19 - * 20 - * Sysfs file creation and management 21 - */ 22 - 23 - #include <linux/kernel.h> 24 - #include <linux/string.h> 25 - #include <linux/errno.h> 26 - #include <linux/unistd.h> 27 - #include <linux/delay.h> 28 - #include <linux/etherdevice.h> 29 - #include <linux/spinlock.h> 30 - #include <linux/mm.h> 31 - #include <linux/device.h> 32 - 33 - #include <asm/uaccess.h> 34 - #include <linux/module.h> 35 - 36 - #include "gianfar.h" 37 - 38 - static ssize_t gfar_show_bd_stash(struct device *dev, 39 - struct device_attribute *attr, char *buf) 40 - { 41 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 42 - 43 - return sprintf(buf, "%s\n", priv->bd_stash_en ? "on" : "off"); 44 - } 45 - 46 - static ssize_t gfar_set_bd_stash(struct device *dev, 47 - struct device_attribute *attr, 48 - const char *buf, size_t count) 49 - { 50 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 51 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 52 - int new_setting = 0; 53 - u32 temp; 54 - unsigned long flags; 55 - 56 - if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BD_STASHING)) 57 - return count; 58 - 59 - 60 - /* Find out the new setting */ 61 - if (!strncmp("on", buf, count - 1) || !strncmp("1", buf, count - 1)) 62 - new_setting = 1; 63 - else if (!strncmp("off", buf, count - 1) || 64 - !strncmp("0", buf, count - 1)) 65 - new_setting = 0; 66 - else 67 - return count; 68 - 69 - 70 - local_irq_save(flags); 71 - lock_rx_qs(priv); 72 - 73 - /* Set the new stashing value */ 74 - priv->bd_stash_en = new_setting; 75 - 76 - temp = gfar_read(&regs->attr); 77 - 78 - if (new_setting) 79 - temp |= ATTR_BDSTASH; 80 - else 81 - temp &= ~(ATTR_BDSTASH); 82 - 83 - gfar_write(&regs->attr, temp); 84 - 85 - unlock_rx_qs(priv); 86 - local_irq_restore(flags); 87 - 88 - return count; 89 - } 90 - 91 - static DEVICE_ATTR(bd_stash, 0644, gfar_show_bd_stash, gfar_set_bd_stash); 92 - 93 - static ssize_t gfar_show_rx_stash_size(struct device *dev, 94 - struct device_attribute *attr, char *buf) 95 - { 96 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 97 - 98 - return sprintf(buf, "%d\n", priv->rx_stash_size); 99 - } 100 - 101 - static ssize_t gfar_set_rx_stash_size(struct device *dev, 102 - struct device_attribute *attr, 103 - const char *buf, size_t count) 104 - { 105 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 106 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 107 - unsigned int length = simple_strtoul(buf, NULL, 0); 108 - u32 temp; 109 - unsigned long flags; 110 - 111 - if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 112 - return count; 113 - 114 - local_irq_save(flags); 115 - lock_rx_qs(priv); 116 - 117 - if (length > priv->rx_buffer_size) 118 - goto out; 119 - 120 - if (length == priv->rx_stash_size) 121 - goto out; 122 - 123 - priv->rx_stash_size = length; 124 - 125 - temp = gfar_read(&regs->attreli); 126 - temp &= ~ATTRELI_EL_MASK; 127 - temp |= ATTRELI_EL(length); 128 - gfar_write(&regs->attreli, temp); 129 - 130 - /* Turn stashing on/off as appropriate */ 131 - temp = gfar_read(&regs->attr); 132 - 133 - if (length) 134 - temp |= ATTR_BUFSTASH; 135 - else 136 - temp &= ~(ATTR_BUFSTASH); 137 - 138 - gfar_write(&regs->attr, temp); 139 - 140 - out: 141 - unlock_rx_qs(priv); 142 - local_irq_restore(flags); 143 - 144 - return count; 145 - } 146 - 147 - static DEVICE_ATTR(rx_stash_size, 0644, gfar_show_rx_stash_size, 148 - gfar_set_rx_stash_size); 149 - 150 - /* Stashing will only be enabled when rx_stash_size != 0 */ 151 - static ssize_t gfar_show_rx_stash_index(struct device *dev, 152 - struct device_attribute *attr, 153 - char *buf) 154 - { 155 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 156 - 157 - return sprintf(buf, "%d\n", priv->rx_stash_index); 158 - } 159 - 160 - static ssize_t gfar_set_rx_stash_index(struct device *dev, 161 - struct device_attribute *attr, 162 - const char *buf, size_t count) 163 - { 164 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 165 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 166 - unsigned short index = simple_strtoul(buf, NULL, 0); 167 - u32 temp; 168 - unsigned long flags; 169 - 170 - if (!(priv->device_flags & FSL_GIANFAR_DEV_HAS_BUF_STASHING)) 171 - return count; 172 - 173 - local_irq_save(flags); 174 - lock_rx_qs(priv); 175 - 176 - if (index > priv->rx_stash_size) 177 - goto out; 178 - 179 - if (index == priv->rx_stash_index) 180 - goto out; 181 - 182 - priv->rx_stash_index = index; 183 - 184 - temp = gfar_read(&regs->attreli); 185 - temp &= ~ATTRELI_EI_MASK; 186 - temp |= ATTRELI_EI(index); 187 - gfar_write(&regs->attreli, temp); 188 - 189 - out: 190 - unlock_rx_qs(priv); 191 - local_irq_restore(flags); 192 - 193 - return count; 194 - } 195 - 196 - static DEVICE_ATTR(rx_stash_index, 0644, gfar_show_rx_stash_index, 197 - gfar_set_rx_stash_index); 198 - 199 - static ssize_t gfar_show_fifo_threshold(struct device *dev, 200 - struct device_attribute *attr, 201 - char *buf) 202 - { 203 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 204 - 205 - return sprintf(buf, "%d\n", priv->fifo_threshold); 206 - } 207 - 208 - static ssize_t gfar_set_fifo_threshold(struct device *dev, 209 - struct device_attribute *attr, 210 - const char *buf, size_t count) 211 - { 212 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 213 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 214 - unsigned int length = simple_strtoul(buf, NULL, 0); 215 - u32 temp; 216 - unsigned long flags; 217 - 218 - if (length > GFAR_MAX_FIFO_THRESHOLD) 219 - return count; 220 - 221 - local_irq_save(flags); 222 - lock_tx_qs(priv); 223 - 224 - priv->fifo_threshold = length; 225 - 226 - temp = gfar_read(&regs->fifo_tx_thr); 227 - temp &= ~FIFO_TX_THR_MASK; 228 - temp |= length; 229 - gfar_write(&regs->fifo_tx_thr, temp); 230 - 231 - unlock_tx_qs(priv); 232 - local_irq_restore(flags); 233 - 234 - return count; 235 - } 236 - 237 - static DEVICE_ATTR(fifo_threshold, 0644, gfar_show_fifo_threshold, 238 - gfar_set_fifo_threshold); 239 - 240 - static ssize_t gfar_show_fifo_starve(struct device *dev, 241 - struct device_attribute *attr, char *buf) 242 - { 243 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 244 - 245 - return sprintf(buf, "%d\n", priv->fifo_starve); 246 - } 247 - 248 - static ssize_t gfar_set_fifo_starve(struct device *dev, 249 - struct device_attribute *attr, 250 - const char *buf, size_t count) 251 - { 252 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 253 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 254 - unsigned int num = simple_strtoul(buf, NULL, 0); 255 - u32 temp; 256 - unsigned long flags; 257 - 258 - if (num > GFAR_MAX_FIFO_STARVE) 259 - return count; 260 - 261 - local_irq_save(flags); 262 - lock_tx_qs(priv); 263 - 264 - priv->fifo_starve = num; 265 - 266 - temp = gfar_read(&regs->fifo_tx_starve); 267 - temp &= ~FIFO_TX_STARVE_MASK; 268 - temp |= num; 269 - gfar_write(&regs->fifo_tx_starve, temp); 270 - 271 - unlock_tx_qs(priv); 272 - local_irq_restore(flags); 273 - 274 - return count; 275 - } 276 - 277 - static DEVICE_ATTR(fifo_starve, 0644, gfar_show_fifo_starve, 278 - gfar_set_fifo_starve); 279 - 280 - static ssize_t gfar_show_fifo_starve_off(struct device *dev, 281 - struct device_attribute *attr, 282 - char *buf) 283 - { 284 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 285 - 286 - return sprintf(buf, "%d\n", priv->fifo_starve_off); 287 - } 288 - 289 - static ssize_t gfar_set_fifo_starve_off(struct device *dev, 290 - struct device_attribute *attr, 291 - const char *buf, size_t count) 292 - { 293 - struct gfar_private *priv = netdev_priv(to_net_dev(dev)); 294 - struct gfar __iomem *regs = priv->gfargrp[0].regs; 295 - unsigned int num = simple_strtoul(buf, NULL, 0); 296 - u32 temp; 297 - unsigned long flags; 298 - 299 - if (num > GFAR_MAX_FIFO_STARVE_OFF) 300 - return count; 301 - 302 - local_irq_save(flags); 303 - lock_tx_qs(priv); 304 - 305 - priv->fifo_starve_off = num; 306 - 307 - temp = gfar_read(&regs->fifo_tx_starve_shutoff); 308 - temp &= ~FIFO_TX_STARVE_OFF_MASK; 309 - temp |= num; 310 - gfar_write(&regs->fifo_tx_starve_shutoff, temp); 311 - 312 - unlock_tx_qs(priv); 313 - local_irq_restore(flags); 314 - 315 - return count; 316 - } 317 - 318 - static DEVICE_ATTR(fifo_starve_off, 0644, gfar_show_fifo_starve_off, 319 - gfar_set_fifo_starve_off); 320 - 321 - void gfar_init_sysfs(struct net_device *dev) 322 - { 323 - struct gfar_private *priv = netdev_priv(dev); 324 - int rc; 325 - 326 - /* Initialize the default values */ 327 - priv->fifo_threshold = DEFAULT_FIFO_TX_THR; 328 - priv->fifo_starve = DEFAULT_FIFO_TX_STARVE; 329 - priv->fifo_starve_off = DEFAULT_FIFO_TX_STARVE_OFF; 330 - 331 - /* Create our sysfs files */ 332 - rc = device_create_file(&dev->dev, &dev_attr_bd_stash); 333 - rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_size); 334 - rc |= device_create_file(&dev->dev, &dev_attr_rx_stash_index); 335 - rc |= device_create_file(&dev->dev, &dev_attr_fifo_threshold); 336 - rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve); 337 - rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve_off); 338 - if (rc) 339 - dev_err(&dev->dev, "Error creating gianfar sysfs files\n"); 340 - }