-static struct attribute veth_active_attr;
-static struct attribute veth_num_attr;
-static struct attribute veth_size_attr;
-
-static ssize_t veth_pool_show(struct kobject * kobj,
- struct attribute * attr, char * buf)
-{
- struct ibmveth_buff_pool *pool = container_of(kobj,
- struct ibmveth_buff_pool,
- kobj);
-
- if (attr == &veth_active_attr)
- return sprintf(buf, "%d\n", pool->active);
- else if (attr == &veth_num_attr)
- return sprintf(buf, "%d\n", pool->size);
- else if (attr == &veth_size_attr)
- return sprintf(buf, "%d\n", pool->buff_size);
- return 0;
-}
-
-static ssize_t veth_pool_store(struct kobject * kobj, struct attribute * attr,
-const char * buf, size_t count)
-{
- struct ibmveth_buff_pool *pool = container_of(kobj,
- struct ibmveth_buff_pool,
- kobj);
- struct net_device *netdev =
- container_of(kobj->parent, struct device, kobj)->driver_data;
- struct ibmveth_adapter *adapter = netdev->priv;
- long value = simple_strtol(buf, NULL, 10);
- long rc;
-
- if (attr == &veth_active_attr) {
- if (value && !pool->active) {
- if(ibmveth_alloc_buffer_pool(pool)) {
- ibmveth_error_printk("unable to alloc pool\n");
- return -ENOMEM;
- }
- pool->active = 1;
- adapter->pool_config = 1;
- ibmveth_close(netdev);
- adapter->pool_config = 0;
- if ((rc = ibmveth_open(netdev)))
- return rc;
- } else if (!value && pool->active) {
- int mtu = netdev->mtu + IBMVETH_BUFF_OH;
- int i;
- /* Make sure there is a buffer pool with buffers that
- can hold a packet of the size of the MTU */
- for(i = 0; i<IbmVethNumBufferPools; i++) {
- if (pool == &adapter->rx_buff_pool[i])
- continue;
- if (!adapter->rx_buff_pool[i].active)
- continue;
- if (mtu < adapter->rx_buff_pool[i].buff_size) {
- pool->active = 0;
- h_free_logical_lan_buffer(adapter->
- vdev->
- unit_address,
- pool->
- buff_size);
- }
- }
- if (pool->active) {
- ibmveth_error_printk("no active pool >= MTU\n");
- return -EPERM;
- }
- }
- } else if (attr == &veth_num_attr) {
- if (value <= 0 || value > IBMVETH_MAX_POOL_COUNT)
- return -EINVAL;
- else {
- adapter->pool_config = 1;
- ibmveth_close(netdev);
- adapter->pool_config = 0;
- pool->size = value;
- if ((rc = ibmveth_open(netdev)))
- return rc;
- }
- } else if (attr == &veth_size_attr) {
- if (value <= IBMVETH_BUFF_OH || value > IBMVETH_MAX_BUF_SIZE)
- return -EINVAL;
- else {
- adapter->pool_config = 1;
- ibmveth_close(netdev);
- adapter->pool_config = 0;
- pool->buff_size = value;
- if ((rc = ibmveth_open(netdev)))
- return rc;
- }
- }
-
- /* kick the interrupt handler to allocate/deallocate pools */
- ibmveth_interrupt(netdev->irq, netdev, NULL);
- return count;
-}
-
-
-#define ATTR(_name, _mode) \
- struct attribute veth_##_name##_attr = { \
- .name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE \
- };
-
-static ATTR(active, 0644);
-static ATTR(num, 0644);
-static ATTR(size, 0644);
-
-static struct attribute * veth_pool_attrs[] = {
- &veth_active_attr,
- &veth_num_attr,
- &veth_size_attr,
- NULL,
-};
-
-static struct sysfs_ops veth_pool_ops = {
- .show = veth_pool_show,
- .store = veth_pool_store,
-};
-
-static struct kobj_type ktype_veth_pool = {
- .release = NULL,
- .sysfs_ops = &veth_pool_ops,
- .default_attrs = veth_pool_attrs,
-};
-
-