Skip to content

[SIG-CLOUD-9] rebase custom changes to 5.14.0-570.23.1.el9 #377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions drivers/net/ethernet/microsoft/mana/mana_en.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ static void mana_pf_deregister_filter(struct mana_port_context *apc)

static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
u32 proto_minor_ver, u32 proto_micro_ver,
u16 *max_num_vports)
u16 *max_num_vports, u8 *bm_hostmode)
{
struct gdma_context *gc = ac->gdma_dev->gdma_context;
struct mana_query_device_cfg_resp resp = {};
Expand All @@ -931,7 +931,7 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,
mana_gd_init_req_hdr(&req.hdr, MANA_QUERY_DEV_CONFIG,
sizeof(req), sizeof(resp));

req.hdr.resp.msg_version = GDMA_MESSAGE_V2;
req.hdr.resp.msg_version = GDMA_MESSAGE_V3;

req.proto_major_ver = proto_major_ver;
req.proto_minor_ver = proto_minor_ver;
Expand All @@ -955,11 +955,16 @@ static int mana_query_device_cfg(struct mana_context *ac, u32 proto_major_ver,

*max_num_vports = resp.max_num_vports;

if (resp.hdr.response.msg_version == GDMA_MESSAGE_V2)
if (resp.hdr.response.msg_version >= GDMA_MESSAGE_V2)
gc->adapter_mtu = resp.adapter_mtu;
else
gc->adapter_mtu = ETH_FRAME_LEN;

if (resp.hdr.response.msg_version >= GDMA_MESSAGE_V3)
*bm_hostmode = resp.bm_hostmode;
else
*bm_hostmode = 0;

debugfs_create_u16("adapter-MTU", 0400, gc->mana_pci_debugfs, &gc->adapter_mtu);

return 0;
Expand Down Expand Up @@ -2439,7 +2444,7 @@ static void mana_destroy_vport(struct mana_port_context *apc)
mana_destroy_txq(apc);
mana_uncfg_vport(apc);

if (gd->gdma_context->is_pf)
if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode)
mana_pf_deregister_hw_vport(apc);
}

Expand All @@ -2451,7 +2456,7 @@ static int mana_create_vport(struct mana_port_context *apc,

apc->default_rxobj = INVALID_MANA_HANDLE;

if (gd->gdma_context->is_pf) {
if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode) {
err = mana_pf_register_hw_vport(apc);
if (err)
return err;
Expand Down Expand Up @@ -2675,7 +2680,7 @@ int mana_alloc_queues(struct net_device *ndev)
if (err)
goto destroy_vport;

if (gd->gdma_context->is_pf) {
if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode) {
err = mana_pf_register_filter(apc);
if (err)
goto destroy_vport;
Expand Down Expand Up @@ -2737,7 +2742,7 @@ static int mana_dealloc_queues(struct net_device *ndev)

mana_chn_setxdp(apc, NULL);

if (gd->gdma_context->is_pf)
if (gd->gdma_context->is_pf && !apc->ac->bm_hostmode)
mana_pf_deregister_filter(apc);

/* No packet can be transmitted now since apc->port_is_up is false.
Expand Down Expand Up @@ -2978,6 +2983,7 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
struct gdma_context *gc = gd->gdma_context;
struct mana_context *ac = gd->driver_data;
struct device *dev = gc->dev;
u8 bm_hostmode = 0;
u16 num_ports = 0;
int err;
int i;
Expand All @@ -3004,10 +3010,12 @@ int mana_probe(struct gdma_dev *gd, bool resuming)
goto out;

err = mana_query_device_cfg(ac, MANA_MAJOR_VERSION, MANA_MINOR_VERSION,
MANA_MICRO_VERSION, &num_ports);
MANA_MICRO_VERSION, &num_ports, &bm_hostmode);
if (err)
goto out;

ac->bm_hostmode = bm_hostmode;

if (!resuming) {
ac->num_ports = num_ports;
} else {
Expand Down
4 changes: 3 additions & 1 deletion include/net/mana/mana.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ struct mana_context {
struct gdma_dev *gdma_dev;

u16 num_ports;
u8 bm_hostmode;

struct mana_eq *eqs;
struct dentry *mana_eqs_debugfs;
Expand Down Expand Up @@ -554,7 +555,8 @@ struct mana_query_device_cfg_resp {
u64 pf_cap_flags4;

u16 max_num_vports;
u16 reserved;
u8 bm_hostmode; /* response v3: Bare Metal Host Mode */
u8 reserved;
u32 max_num_eqs;

/* response v2: */
Expand Down
64 changes: 59 additions & 5 deletions tools/hv/hv_kvp_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum {
};

static int in_hand_shake;
static int debug;

static char *os_name = "";
static char *os_major = "";
Expand Down Expand Up @@ -172,6 +173,20 @@ static void kvp_update_file(int pool)
kvp_release_lock(pool);
}

static void kvp_dump_initial_pools(int pool)
{
int i;

syslog(LOG_DEBUG, "===Start dumping the contents of pool %d ===\n",
pool);

for (i = 0; i < kvp_file_info[pool].num_records; i++)
syslog(LOG_DEBUG, "pool: %d, %d/%d key=%s val=%s\n",
pool, i + 1, kvp_file_info[pool].num_records,
kvp_file_info[pool].records[i].key,
kvp_file_info[pool].records[i].value);
}

static void kvp_update_mem_state(int pool)
{
FILE *filep;
Expand Down Expand Up @@ -259,6 +274,8 @@ static int kvp_file_init(void)
return 1;
kvp_file_info[i].num_records = 0;
kvp_update_mem_state(i);
if (debug)
kvp_dump_initial_pools(i);
}

return 0;
Expand Down Expand Up @@ -286,6 +303,9 @@ static int kvp_key_delete(int pool, const __u8 *key, int key_size)
* Found a match; just move the remaining
* entries up.
*/
if (debug)
syslog(LOG_DEBUG, "%s: deleting the KVP: pool=%d key=%s val=%s",
__func__, pool, record[i].key, record[i].value);
if (i == (num_records - 1)) {
kvp_file_info[pool].num_records--;
kvp_update_file(pool);
Expand All @@ -304,20 +324,36 @@ static int kvp_key_delete(int pool, const __u8 *key, int key_size)
kvp_update_file(pool);
return 0;
}

if (debug)
syslog(LOG_DEBUG, "%s: could not delete KVP: pool=%d key=%s. Record not found",
__func__, pool, key);

return 1;
}

static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size,
const __u8 *value, int value_size)
{
int i;
int num_records;
struct kvp_record *record;
int num_records;
int num_blocks;
int i;

if (debug)
syslog(LOG_DEBUG, "%s: got a KVP: pool=%d key=%s val=%s",
__func__, pool, key, value);

if ((key_size > HV_KVP_EXCHANGE_MAX_KEY_SIZE) ||
(value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE))
(value_size > HV_KVP_EXCHANGE_MAX_VALUE_SIZE)) {
syslog(LOG_ERR, "%s: Too long key or value: key=%s, val=%s",
__func__, key, value);

if (debug)
syslog(LOG_DEBUG, "%s: Too long key or value: pool=%d, key=%s, val=%s",
__func__, pool, key, value);
return 1;
}

/*
* First update the in-memory state.
Expand All @@ -337,6 +373,9 @@ static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size,
*/
memcpy(record[i].value, value, value_size);
kvp_update_file(pool);
if (debug)
syslog(LOG_DEBUG, "%s: updated: pool=%d key=%s val=%s",
__func__, pool, key, value);
return 0;
}

Expand All @@ -348,15 +387,22 @@ static int kvp_key_add_or_modify(int pool, const __u8 *key, int key_size,
record = realloc(record, sizeof(struct kvp_record) *
ENTRIES_PER_BLOCK * (num_blocks + 1));

if (record == NULL)
if (!record) {
syslog(LOG_ERR, "%s: Memory alloc failure", __func__);
return 1;
}
kvp_file_info[pool].num_blocks++;

}
memcpy(record[i].value, value, value_size);
memcpy(record[i].key, key, key_size);
kvp_file_info[pool].records = record;
kvp_file_info[pool].num_records++;

if (debug)
syslog(LOG_DEBUG, "%s: added: pool=%d key=%s val=%s",
__func__, pool, key, value);

kvp_update_file(pool);
return 0;
}
Expand Down Expand Up @@ -1355,6 +1401,7 @@ void print_usage(char *argv[])
fprintf(stderr, "Usage: %s [options]\n"
"Options are:\n"
" -n, --no-daemon stay in foreground, don't daemonize\n"
" -d, --debug Enable debug logs(syslog debug by default)\n"
" -h, --help print this help\n", argv[0]);
}

Expand All @@ -1376,10 +1423,11 @@ int main(int argc, char *argv[])
static struct option long_options[] = {
{"help", no_argument, 0, 'h' },
{"no-daemon", no_argument, 0, 'n' },
{"debug", no_argument, 0, 'd' },
{0, 0, 0, 0 }
};

while ((opt = getopt_long(argc, argv, "hn", long_options,
while ((opt = getopt_long(argc, argv, "hnd", long_options,
&long_index)) != -1) {
switch (opt) {
case 'n':
Expand All @@ -1388,6 +1436,9 @@ int main(int argc, char *argv[])
case 'h':
print_usage(argv);
exit(0);
case 'd':
debug = 1;
break;
default:
print_usage(argv);
exit(EXIT_FAILURE);
Expand All @@ -1410,6 +1461,9 @@ int main(int argc, char *argv[])
*/
kvp_get_domain_name(full_domain_name, sizeof(full_domain_name));

if (debug)
syslog(LOG_INFO, "Logging debug info in syslog(debug)");

if (kvp_file_init()) {
syslog(LOG_ERR, "Failed to initialize the pools");
exit(EXIT_FAILURE);
Expand Down
4 changes: 4 additions & 0 deletions tools/testing/selftests/mm/hmm-tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ FIXTURE_TEARDOWN(hmm)
{
int ret = close(self->fd);

if (ret != 0) {
fprintf(stderr, "close returned (%d) fd is (%d)\n", ret, self->fd);
exit(1);
}
ASSERT_EQ(ret, 0);
self->fd = -1;
}
Expand Down