Updated `README.md` with instructions for building/using the kernel module.
[xeon-phi-kernel-module] / vnet / micveth_param.c
CommitLineData
800f879a
AT
1/*
2 * Copyright 2010-2017 Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * Disclaimer: The codes contained in these modules may be specific to
14 * the Intel Software Development Platform codenamed Knights Ferry,
15 * and the Intel product codenamed Knights Corner, and are not backward
16 * compatible with other Intel products. Additionally, Intel will NOT
17 * support the codes or instruction set in future products.
18 *
19 * Intel offers no warranty of any kind regarding the code. This code is
20 * licensed on an "AS IS" basis and Intel is not obligated to provide
21 * any support, assistance, installation, training, or other services
22 * of any kind. Intel is also not obligated to provide any updates,
23 * enhancements or extensions. Intel specifically disclaims any warranty
24 * of merchantability, non-infringement, fitness for any particular
25 * purpose, and any other warranty.
26 *
27 * Further, Intel disclaims all liability of any kind, including but
28 * not limited to liability for infringement of any proprietary rights,
29 * relating to the use of the code, even if Intel is notified of the
30 * possibility of such liability. Except as expressly stated in an Intel
31 * license agreement provided with this code and agreed upon with Intel,
32 * no license, express or implied, by estoppel or otherwise, to any
33 * intellectual property rights is granted herein.
34 */
35
36#include <linux/module.h>
37#include <linux/string.h>
38#include <linux/errno.h>
39#include <linux/version.h>
40
41#include "mic/micveth.h"
42
43#define __VNET_MODE(u, l) #l ,
44char *mic_vnet_modes[] = { VNET_MODES };
45#undef __VNET_MODE
46
47/*
48 *KAA: not sure when this API changed, could have been in 35.
49 */
50#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
51#define GRRR const
52#else
53#define GRRR /* As nothing */
54#endif
55
56static int param_set_vnetmode(const char *val, GRRR struct kernel_param *kp)
57{
58 int i;
59 for (i = 0; i < sizeof(mic_vnet_modes) / sizeof(char *); i++)
60 if (!strcmp(val, mic_vnet_modes[i])) {
61 mic_vnet_mode = i;
62 return 0;
63 }
64 return -EINVAL;
65}
66
67static int param_get_vnetmode(char *buffer, GRRR struct kernel_param *kp)
68{
69 return sprintf(buffer, "%s", mic_vnet_modes[mic_vnet_mode]);
70}
71
72#define param_check_vnetmode(name, p) __param_check(name, p, int)
73
74#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
75struct kernel_param_ops param_ops_vnetmode = {
76 .set = param_set_vnetmode,
77 .get = param_get_vnetmode,
78};
79#endif /* Kernel > 2.6.36 */
80
81int mic_vnet_mode = VNET_MODE_DMA;
82module_param_named(vnet, mic_vnet_mode, vnetmode, 0400);
83#define __VNET_MODE(u, l) " " #l
84MODULE_PARM_DESC(vnet, "Vnet operating mode, one of:" VNET_MODES);
85#undef __VNET_MODE
86
87int vnet_num_buffers = VNET_MAX_SKBS;
88module_param(vnet_num_buffers, int, 0400);
89MODULE_PARM_DESC(vnet_num_buffers, "Number of buffers used by the VNET driver");
90
91ulong vnet_addr = 0;
92module_param(vnet_addr, ulong, 0400);
93MODULE_PARM_DESC(vnet_addr, "Vnet driver host ring address");
94
95