diff options
Diffstat (limited to 'drivers/net/ethernet/qlogic/netxen')
-rw-r--r-- | drivers/net/ethernet/qlogic/netxen/netxen_nic.h | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h | 25 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 131 |
3 files changed, 163 insertions, 0 deletions
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h index ecc8d1769708..11b4922a1781 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h | |||
@@ -1817,6 +1817,13 @@ struct netxen_brdinfo { | |||
1817 | char short_name[NETXEN_MAX_SHORT_NAME]; | 1817 | char short_name[NETXEN_MAX_SHORT_NAME]; |
1818 | }; | 1818 | }; |
1819 | 1819 | ||
1820 | struct netxen_dimm_cfg { | ||
1821 | u8 presence; | ||
1822 | u8 mem_type; | ||
1823 | u8 dimm_type; | ||
1824 | u32 size; | ||
1825 | }; | ||
1826 | |||
1820 | static const struct netxen_brdinfo netxen_boards[] = { | 1827 | static const struct netxen_brdinfo netxen_boards[] = { |
1821 | {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"}, | 1828 | {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"}, |
1822 | {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"}, | 1829 | {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"}, |
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h index b1a897cd9a8d..a41106ba9719 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h | |||
@@ -955,6 +955,31 @@ enum { | |||
955 | #define NX_CRB_DEV_REF_COUNT (NETXEN_CAM_RAM(0x138)) | 955 | #define NX_CRB_DEV_REF_COUNT (NETXEN_CAM_RAM(0x138)) |
956 | #define NX_CRB_DEV_STATE (NETXEN_CAM_RAM(0x140)) | 956 | #define NX_CRB_DEV_STATE (NETXEN_CAM_RAM(0x140)) |
957 | 957 | ||
958 | /* MiniDIMM related macros */ | ||
959 | #define NETXEN_DIMM_CAPABILITY (NETXEN_CAM_RAM(0x258)) | ||
960 | #define NETXEN_DIMM_PRESENT 0x1 | ||
961 | #define NETXEN_DIMM_MEMTYPE_DDR2_SDRAM 0x2 | ||
962 | #define NETXEN_DIMM_SIZE 0x4 | ||
963 | #define NETXEN_DIMM_MEMTYPE(VAL) ((VAL >> 3) & 0xf) | ||
964 | #define NETXEN_DIMM_NUMROWS(VAL) ((VAL >> 7) & 0xf) | ||
965 | #define NETXEN_DIMM_NUMCOLS(VAL) ((VAL >> 11) & 0xf) | ||
966 | #define NETXEN_DIMM_NUMRANKS(VAL) ((VAL >> 15) & 0x3) | ||
967 | #define NETXEN_DIMM_DATAWIDTH(VAL) ((VAL >> 18) & 0x3) | ||
968 | #define NETXEN_DIMM_NUMBANKS(VAL) ((VAL >> 21) & 0xf) | ||
969 | #define NETXEN_DIMM_TYPE(VAL) ((VAL >> 25) & 0x3f) | ||
970 | #define NETXEN_DIMM_VALID_FLAG 0x80000000 | ||
971 | |||
972 | #define NETXEN_DIMM_MEM_DDR2_SDRAM 0x8 | ||
973 | |||
974 | #define NETXEN_DIMM_STD_MEM_SIZE 512 | ||
975 | |||
976 | #define NETXEN_DIMM_TYPE_RDIMM 0x1 | ||
977 | #define NETXEN_DIMM_TYPE_UDIMM 0x2 | ||
978 | #define NETXEN_DIMM_TYPE_SO_DIMM 0x4 | ||
979 | #define NETXEN_DIMM_TYPE_Micro_DIMM 0x8 | ||
980 | #define NETXEN_DIMM_TYPE_Mini_RDIMM 0x10 | ||
981 | #define NETXEN_DIMM_TYPE_Mini_UDIMM 0x20 | ||
982 | |||
958 | /* Device State */ | 983 | /* Device State */ |
959 | #define NX_DEV_COLD 1 | 984 | #define NX_DEV_COLD 1 |
960 | #define NX_DEV_INITALIZING 2 | 985 | #define NX_DEV_INITALIZING 2 |
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c index 65a718f9ccd3..d03619cab8dd 100644 --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | |||
@@ -2926,6 +2926,134 @@ static struct bin_attribute bin_attr_mem = { | |||
2926 | .write = netxen_sysfs_write_mem, | 2926 | .write = netxen_sysfs_write_mem, |
2927 | }; | 2927 | }; |
2928 | 2928 | ||
2929 | static ssize_t | ||
2930 | netxen_sysfs_read_dimm(struct file *filp, struct kobject *kobj, | ||
2931 | struct bin_attribute *attr, | ||
2932 | char *buf, loff_t offset, size_t size) | ||
2933 | { | ||
2934 | struct device *dev = container_of(kobj, struct device, kobj); | ||
2935 | struct netxen_adapter *adapter = dev_get_drvdata(dev); | ||
2936 | struct net_device *netdev = adapter->netdev; | ||
2937 | struct netxen_dimm_cfg dimm; | ||
2938 | u8 dw, rows, cols, banks, ranks; | ||
2939 | u32 val; | ||
2940 | |||
2941 | if (size != sizeof(struct netxen_dimm_cfg)) { | ||
2942 | netdev_err(netdev, "Invalid size\n"); | ||
2943 | return -1; | ||
2944 | } | ||
2945 | |||
2946 | memset(&dimm, 0, sizeof(struct netxen_dimm_cfg)); | ||
2947 | val = NXRD32(adapter, NETXEN_DIMM_CAPABILITY); | ||
2948 | |||
2949 | /* Checks if DIMM info is valid. */ | ||
2950 | if (val & NETXEN_DIMM_VALID_FLAG) { | ||
2951 | netdev_err(netdev, "Invalid DIMM flag\n"); | ||
2952 | dimm.presence = 0xff; | ||
2953 | goto out; | ||
2954 | } | ||
2955 | |||
2956 | rows = NETXEN_DIMM_NUMROWS(val); | ||
2957 | cols = NETXEN_DIMM_NUMCOLS(val); | ||
2958 | ranks = NETXEN_DIMM_NUMRANKS(val); | ||
2959 | banks = NETXEN_DIMM_NUMBANKS(val); | ||
2960 | dw = NETXEN_DIMM_DATAWIDTH(val); | ||
2961 | |||
2962 | dimm.presence = (val & NETXEN_DIMM_PRESENT); | ||
2963 | |||
2964 | /* Checks if DIMM info is present. */ | ||
2965 | if (!dimm.presence) { | ||
2966 | netdev_err(netdev, "DIMM not present\n"); | ||
2967 | goto out; | ||
2968 | } | ||
2969 | |||
2970 | dimm.dimm_type = NETXEN_DIMM_TYPE(val); | ||
2971 | |||
2972 | switch (dimm.dimm_type) { | ||
2973 | case NETXEN_DIMM_TYPE_RDIMM: | ||
2974 | case NETXEN_DIMM_TYPE_UDIMM: | ||
2975 | case NETXEN_DIMM_TYPE_SO_DIMM: | ||
2976 | case NETXEN_DIMM_TYPE_Micro_DIMM: | ||
2977 | case NETXEN_DIMM_TYPE_Mini_RDIMM: | ||
2978 | case NETXEN_DIMM_TYPE_Mini_UDIMM: | ||
2979 | break; | ||
2980 | default: | ||
2981 | netdev_err(netdev, "Invalid DIMM type %x\n", dimm.dimm_type); | ||
2982 | goto out; | ||
2983 | } | ||
2984 | |||
2985 | if (val & NETXEN_DIMM_MEMTYPE_DDR2_SDRAM) | ||
2986 | dimm.mem_type = NETXEN_DIMM_MEM_DDR2_SDRAM; | ||
2987 | else | ||
2988 | dimm.mem_type = NETXEN_DIMM_MEMTYPE(val); | ||
2989 | |||
2990 | if (val & NETXEN_DIMM_SIZE) { | ||
2991 | dimm.size = NETXEN_DIMM_STD_MEM_SIZE; | ||
2992 | goto out; | ||
2993 | } | ||
2994 | |||
2995 | if (!rows) { | ||
2996 | netdev_err(netdev, "Invalid no of rows %x\n", rows); | ||
2997 | goto out; | ||
2998 | } | ||
2999 | |||
3000 | if (!cols) { | ||
3001 | netdev_err(netdev, "Invalid no of columns %x\n", cols); | ||
3002 | goto out; | ||
3003 | } | ||
3004 | |||
3005 | if (!banks) { | ||
3006 | netdev_err(netdev, "Invalid no of banks %x\n", banks); | ||
3007 | goto out; | ||
3008 | } | ||
3009 | |||
3010 | ranks += 1; | ||
3011 | |||
3012 | switch (dw) { | ||
3013 | case 0x0: | ||
3014 | dw = 32; | ||
3015 | break; | ||
3016 | case 0x1: | ||
3017 | dw = 33; | ||
3018 | break; | ||
3019 | case 0x2: | ||
3020 | dw = 36; | ||
3021 | break; | ||
3022 | case 0x3: | ||
3023 | dw = 64; | ||
3024 | break; | ||
3025 | case 0x4: | ||
3026 | dw = 72; | ||
3027 | break; | ||
3028 | case 0x5: | ||
3029 | dw = 80; | ||
3030 | break; | ||
3031 | case 0x6: | ||
3032 | dw = 128; | ||
3033 | break; | ||
3034 | case 0x7: | ||
3035 | dw = 144; | ||
3036 | break; | ||
3037 | default: | ||
3038 | netdev_err(netdev, "Invalid data-width %x\n", dw); | ||
3039 | goto out; | ||
3040 | } | ||
3041 | |||
3042 | dimm.size = ((1 << rows) * (1 << cols) * dw * banks * ranks) / 8; | ||
3043 | /* Size returned in MB. */ | ||
3044 | dimm.size = (dimm.size) / 0x100000; | ||
3045 | out: | ||
3046 | memcpy(buf, &dimm, sizeof(struct netxen_dimm_cfg)); | ||
3047 | return sizeof(struct netxen_dimm_cfg); | ||
3048 | |||
3049 | } | ||
3050 | |||
3051 | static struct bin_attribute bin_attr_dimm = { | ||
3052 | .attr = { .name = "dimm", .mode = (S_IRUGO | S_IWUSR) }, | ||
3053 | .size = 0, | ||
3054 | .read = netxen_sysfs_read_dimm, | ||
3055 | }; | ||
3056 | |||
2929 | 3057 | ||
2930 | static void | 3058 | static void |
2931 | netxen_create_sysfs_entries(struct netxen_adapter *adapter) | 3059 | netxen_create_sysfs_entries(struct netxen_adapter *adapter) |
@@ -2963,6 +3091,8 @@ netxen_create_diag_entries(struct netxen_adapter *adapter) | |||
2963 | dev_info(dev, "failed to create crb sysfs entry\n"); | 3091 | dev_info(dev, "failed to create crb sysfs entry\n"); |
2964 | if (device_create_bin_file(dev, &bin_attr_mem)) | 3092 | if (device_create_bin_file(dev, &bin_attr_mem)) |
2965 | dev_info(dev, "failed to create mem sysfs entry\n"); | 3093 | dev_info(dev, "failed to create mem sysfs entry\n"); |
3094 | if (device_create_bin_file(dev, &bin_attr_dimm)) | ||
3095 | dev_info(dev, "failed to create dimm sysfs entry\n"); | ||
2966 | } | 3096 | } |
2967 | 3097 | ||
2968 | 3098 | ||
@@ -2975,6 +3105,7 @@ netxen_remove_diag_entries(struct netxen_adapter *adapter) | |||
2975 | device_remove_file(dev, &dev_attr_diag_mode); | 3105 | device_remove_file(dev, &dev_attr_diag_mode); |
2976 | device_remove_bin_file(dev, &bin_attr_crb); | 3106 | device_remove_bin_file(dev, &bin_attr_crb); |
2977 | device_remove_bin_file(dev, &bin_attr_mem); | 3107 | device_remove_bin_file(dev, &bin_attr_mem); |
3108 | device_remove_bin_file(dev, &bin_attr_dimm); | ||
2978 | } | 3109 | } |
2979 | 3110 | ||
2980 | #ifdef CONFIG_INET | 3111 | #ifdef CONFIG_INET |