nm-setting-dcb.c 37.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */

/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
19
 * Copyright 2013 Red Hat, Inc.
20 21
 */

22
#include "nm-default.h"
23

24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#include <string.h>
#include <dbus/dbus-glib.h>

#include "nm-setting-dcb.h"
#include "nm-param-spec-specialized.h"
#include "nm-utils.h"
#include "nm-utils-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-setting-private.h"

/**
 * SECTION:nm-setting-dcb
 * @short_description: Connection properties for Data Center Bridging
 * @include: nm-setting-dcb.h
 *
 * The #NMSettingDcb object is a #NMSetting subclass that describes properties
 * for enabling and using Data Center Bridging (DCB) on Ethernet networks.
 * DCB is a set of protocols (including 802.1Qbb, 802.1Qaz, 802.1Qau, and
 * 802.1AB) to eliminate packet loss in Ethernet networks and support the use
 * of storage technologies like Fibre Channel over Ethernet (FCoE) and iSCSI.
 *
 * Since: 0.9.10
 **/

/**
 * nm_setting_dcb_error_quark:
 *
 * Registers an error quark for #NMSettingDcb if necessary.
 *
 * Returns: the error quark used for #NMSettingDcb errors.
 *
 * Since: 0.9.10
 **/
GQuark
nm_setting_dcb_error_quark (void)
{
	static GQuark quark;

	if (G_UNLIKELY (!quark))
		quark = g_quark_from_static_string ("nm-setting-dcb-error-quark");
	return quark;
}

G_DEFINE_TYPE_WITH_CODE (NMSettingDcb, nm_setting_dcb, NM_TYPE_SETTING,
                         _nm_register_setting (NM_SETTING_DCB_SETTING_NAME,
                                               g_define_type_id,
                                               2,
                                               NM_SETTING_DCB_ERROR))
NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_DCB)

#define NM_SETTING_DCB_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_DCB, NMSettingDcbPrivate))

typedef struct {
	NMSettingDcbFlags app_fcoe_flags;
78
	int               app_fcoe_priority;
79
	char *            app_fcoe_mode;
80 81

	NMSettingDcbFlags app_iscsi_flags;
82
	int               app_iscsi_priority;
83 84

	NMSettingDcbFlags app_fip_flags;
85
	int               app_fip_priority;
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163

	/* Priority Flow Control */
	NMSettingDcbFlags pfc_flags;
	guint             pfc[8];

	/* Priority Groups */
	NMSettingDcbFlags priority_group_flags;
	guint             priority_group_id[8];
	guint             priority_group_bandwidth[8];
	guint             priority_bandwidth[8];
	guint             priority_strict[8];
	guint             priority_traffic_class[8];
} NMSettingDcbPrivate;

enum {
	PROP_0,
	PROP_APP_FCOE_FLAGS,
	PROP_APP_FCOE_PRIORITY,
	PROP_APP_FCOE_MODE,

	PROP_APP_ISCSI_FLAGS,
	PROP_APP_ISCSI_PRIORITY,

	PROP_APP_FIP_FLAGS,
	PROP_APP_FIP_PRIORITY,

	PROP_PFC_FLAGS,
	PROP_PFC,

	PROP_PRIORITY_GROUP_FLAGS,
	PROP_PRIORITY_GROUP_ID,
	PROP_PRIORITY_GROUP_BANDWIDTH,
	PROP_PRIORITY_BANDWIDTH,
	PROP_PRIORITY_STRICT,
	PROP_PRIORITY_TRAFFIC_CLASS,

	LAST_PROP
};

/**
 * nm_setting_dcb_new:
 *
 * Creates a new #NMSettingDcb object with default values.
 *
 * Returns: (transfer full): the new empty #NMSettingDcb object
 *
 * Since: 0.9.10
 **/
NMSetting *
nm_setting_dcb_new (void)
{
	return (NMSetting *) g_object_new (NM_TYPE_SETTING_DCB, NULL);
}

/**
 * nm_setting_dcb_get_app_fcoe_flags:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-fcoe-flags property of the setting
 *
 * Since: 0.9.10
 **/
NMSettingDcbFlags
nm_setting_dcb_get_app_fcoe_flags (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_flags;
}

/**
 * nm_setting_dcb_get_app_fcoe_priority:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-fcoe-priority property of the setting
 *
 * Since: 0.9.10
 **/
164
int
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
nm_setting_dcb_get_app_fcoe_priority (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_priority;
}

/**
 * nm_setting_dcb_get_app_fcoe_mode:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-fcoe-mode property of the setting
 *
 * Since: 0.9.10
 **/
const char *
nm_setting_dcb_get_app_fcoe_mode (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), NULL);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fcoe_mode;
}

/**
 * nm_setting_dcb_get_app_iscsi_flags:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-iscsi-flags property of the setting
 *
 * Since: 0.9.10
 **/
NMSettingDcbFlags
nm_setting_dcb_get_app_iscsi_flags (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_flags;
}

/**
 * nm_setting_dcb_get_app_iscsi_priority:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-iscsi-priority property of the setting
 *
 * Since: 0.9.10
 **/
212
int
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
nm_setting_dcb_get_app_iscsi_priority (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_iscsi_priority;
}

/**
 * nm_setting_dcb_get_app_fip_flags:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-fip-flags property of the setting
 *
 * Since: 0.9.10
 **/
NMSettingDcbFlags
nm_setting_dcb_get_app_fip_flags (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_flags;
}

/**
 * nm_setting_dcb_get_app_fip_priority:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:app-fip-priority property of the setting
 *
 * Since: 0.9.10
 **/
244
int
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
nm_setting_dcb_get_app_fip_priority (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->app_fip_priority;
}

/**
 * nm_setting_dcb_get_priority_flow_control_flags:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:priority-flow-control-flags property of the setting
 *
 * Since: 0.9.10
 **/
NMSettingDcbFlags
nm_setting_dcb_get_priority_flow_control_flags (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->pfc_flags;
}

/**
 * nm_setting_dcb_get_priority_flow_control:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to retrieve flow control for
 *
 * Returns: %TRUE if flow control is enabled for the given @user_priority,
 * %FALSE if not enabled
 *
 * Since: 0.9.10
 **/
gboolean
nm_setting_dcb_get_priority_flow_control (NMSettingDcb *setting, guint user_priority)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), FALSE);
	g_return_val_if_fail (user_priority <= 7, FALSE);

	return !!NM_SETTING_DCB_GET_PRIVATE (setting)->pfc[user_priority];
}

/**
 * nm_setting_dcb_set_priority_flow_control:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to set flow control for
 * @enabled: %TRUE to enable flow control for this priority, %FALSE to disable it
 *
 * These values are only valid when #NMSettingDcb:priority-flow-control includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_flow_control (NMSettingDcb *setting,
                                          guint user_priority,
                                          gboolean enabled)
{
	NMSettingDcbPrivate *priv;
	guint uint_enabled = enabled ? 1 : 0;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (user_priority <= 7);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->pfc[user_priority] != uint_enabled) {
		priv->pfc[user_priority] = uint_enabled;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_FLOW_CONTROL);
	}
}

/**
 * nm_setting_dcb_get_priority_group_flags:
 * @setting: the #NMSettingDcb
 *
 * Returns: the #NMSettingDcb:priority-group-flags property of the setting
 *
 * Since: 0.9.10
 **/
NMSettingDcbFlags
nm_setting_dcb_get_priority_group_flags (NMSettingDcb *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_flags;
}

/**
 * nm_setting_dcb_get_priority_group_id:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to retrieve the group ID for
 *
 * Returns: the group number @user_priority is assigned to.  These values are
 * only valid when #NMSettingDcb:priority-group-flags includes the
 * %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
guint
nm_setting_dcb_get_priority_group_id (NMSettingDcb *setting, guint user_priority)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
	g_return_val_if_fail (user_priority <= 7, 0);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_id[user_priority];
}

/**
 * nm_setting_dcb_set_priority_group_id:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to set flow control for
 * @group_id: the group (0 - 7) to assign @user_priority to, or 15 for the
 * unrestricted group.
 *
 * These values are only valid when #NMSettingDcb:priority-group-flags includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_group_id (NMSettingDcb *setting,
                                      guint user_priority,
                                      guint group_id)
{
	NMSettingDcbPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (user_priority <= 7);
	g_return_if_fail (group_id <= 7 || group_id == 15);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->priority_group_id[user_priority] != group_id) {
		priv->priority_group_id[user_priority] = group_id;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_ID);
	}
}

/**
 * nm_setting_dcb_get_priority_group_bandwidth:
 * @setting: the #NMSettingDcb
 * @group_id: the priority group (0 - 7) to retrieve the bandwidth percentage for
 *
 * Returns: the bandwidth percentage assigned to @group_id.  These values are
 * only valid when #NMSettingDcb:priority-group-flags includes the
 * %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
guint
nm_setting_dcb_get_priority_group_bandwidth (NMSettingDcb *setting, guint group_id)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
	g_return_val_if_fail (group_id <= 7, FALSE);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_group_bandwidth[group_id];
}

/**
 * nm_setting_dcb_set_priority_group_bandwidth:
 * @setting: the #NMSettingDcb
 * @group_id: the priority group (0 - 7) to set the bandwidth percentage for
 * @bandwidth_percent: the bandwidth percentage (0 - 100) to assign to @group_id to
 *
 * These values are only valid when #NMSettingDcb:priority-group-flags includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_group_bandwidth (NMSettingDcb *setting,
                                             guint group_id,
                                             guint bandwidth_percent)
{
	NMSettingDcbPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (group_id <= 7);
	g_return_if_fail (bandwidth_percent <= 100);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->priority_group_bandwidth[group_id] != bandwidth_percent) {
		priv->priority_group_bandwidth[group_id] = bandwidth_percent;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH);
	}
}

/**
 * nm_setting_dcb_get_priority_bandwidth:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to retrieve the group bandwidth percentage for
 *
 * Returns: the allowed bandwidth percentage of @user_priority in its priority group.
 * These values are only valid when #NMSettingDcb:priority-group-flags includes the
 * %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
guint
nm_setting_dcb_get_priority_bandwidth (NMSettingDcb *setting, guint user_priority)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
	g_return_val_if_fail (user_priority <= 7, FALSE);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_bandwidth[user_priority];
}

/**
 * nm_setting_dcb_set_priority_bandwidth:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
 * @bandwidth_percent: the bandwidth percentage (0 - 100) that @user_priority is
 * allowed to use within its priority group
 *
 * These values are only valid when #NMSettingDcb:priority-group-flags includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_bandwidth (NMSettingDcb *setting,
                                       guint user_priority,
                                       guint bandwidth_percent)
{
	NMSettingDcbPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (user_priority <= 7);
	g_return_if_fail (bandwidth_percent <= 100);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->priority_bandwidth[user_priority] != bandwidth_percent) {
		priv->priority_bandwidth[user_priority] = bandwidth_percent;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_BANDWIDTH);
	}
}

/**
 * nm_setting_dcb_get_priority_strict_bandwidth:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to retrieve strict bandwidth for
 *
 * Returns: %TRUE if @user_priority may use all of the bandwidth allocated to its
 * assigned group, or %FALSE if not. These values are only valid when
 * #NMSettingDcb:priority-group-flags includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
gboolean
nm_setting_dcb_get_priority_strict_bandwidth (NMSettingDcb *setting, guint user_priority)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
	g_return_val_if_fail (user_priority <= 7, FALSE);

	return !!NM_SETTING_DCB_GET_PRIVATE (setting)->priority_strict[user_priority];
}

/**
 * nm_setting_dcb_set_priority_strict_bandwidth:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to set strict bandwidth for
 * @strict: %TRUE to allow @user_priority to use all the bandwidth allocated to
 * its priority group, or %FALSE if not
 *
 * These values are only valid when #NMSettingDcb:priority-group-flags includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_strict_bandwidth (NMSettingDcb *setting,
                                              guint user_priority,
                                              gboolean strict)
{
	NMSettingDcbPrivate *priv;
	guint uint_strict = strict ? 1 : 0;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (user_priority <= 7);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->priority_strict[user_priority] != uint_strict) {
		priv->priority_strict[user_priority] = uint_strict;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH);
	}
}

/**
 * nm_setting_dcb_get_priority_traffic_class:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to retrieve the traffic class for
 *
 * Returns: the traffic class assigned to @user_priority. These values are only
 * valid when #NMSettingDcb:priority-group-flags includes the
 * %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
guint
nm_setting_dcb_get_priority_traffic_class (NMSettingDcb *setting, guint user_priority)
{
	g_return_val_if_fail (NM_IS_SETTING_DCB (setting), 0);
	g_return_val_if_fail (user_priority <= 7, FALSE);

	return NM_SETTING_DCB_GET_PRIVATE (setting)->priority_traffic_class[user_priority];
}

/**
 * nm_setting_dcb_set_priority_traffic_clas:
 * @setting: the #NMSettingDcb
 * @user_priority: the User Priority (0 - 7) to set the bandwidth percentage for
 * @traffic_class: the traffic_class (0 - 7) that @user_priority should map to
 *
 * These values are only valid when #NMSettingDcb:priority-group-flags includes
 * the %NM_SETTING_DCB_FLAG_ENABLE flag.
 *
 * Since: 0.9.10
 **/
void
nm_setting_dcb_set_priority_traffic_class (NMSettingDcb *setting,
                                           guint user_priority,
                                           guint traffic_class)
{
	NMSettingDcbPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_DCB (setting));
	g_return_if_fail (user_priority <= 7);
	g_return_if_fail (traffic_class <= 7);

	priv = NM_SETTING_DCB_GET_PRIVATE (setting);
	if (priv->priority_traffic_class[user_priority] != traffic_class) {
		priv->priority_traffic_class[user_priority] = traffic_class;
		g_object_notify (G_OBJECT (setting), NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS);
	}
}

580
/*****************************************************************************/
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667

#define DCB_FLAGS_ALL (NM_SETTING_DCB_FLAG_ENABLE | \
                       NM_SETTING_DCB_FLAG_ADVERTISE | \
                       NM_SETTING_DCB_FLAG_WILLING)

static gboolean
check_dcb_flags (NMSettingDcbFlags flags, const char *prop_name, GError **error)
{
	if (flags & ~DCB_FLAGS_ALL) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
		                     _("flags invalid"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
		return FALSE;
	}

	if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (flags & ~NM_SETTING_DCB_FLAG_ENABLE)) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
		                     _("flags invalid - disabled"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
		return FALSE;
	}

	return TRUE;
}

static gboolean
check_uint_array (const guint *array,
                  guint len,
                  NMSettingDcbFlags flags,
                  guint max,
                  guint extra,
                  gboolean sum_pct,
                  const char *prop_name,
                  GError **error)
{
	guint i, sum = 0;

	/* Ensure each element is <= to max or equals extra */
	for (i = 0; i < len; i++) {
		if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && array[i]) {
			g_set_error_literal (error,
			                     NM_SETTING_DCB_ERROR,
			                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
			                     _("property invalid (not enabled)"));
			g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
			return FALSE;
		}

		if ((array[i] > max) && (array[i] != extra)) {
			g_set_error_literal (error,
			                     NM_SETTING_DCB_ERROR,
			                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
			                     _("element invalid"));
			g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
			return FALSE;
		}
		sum += array[i];
	}

	/* Verify sum of percentages */
	if (sum_pct) {
		if (flags & NM_SETTING_DCB_FLAG_ENABLE) {
			/* If the feature is enabled, sum must equal 100% */
			if (sum != 100) {
				g_set_error_literal (error,
				                     NM_SETTING_DCB_ERROR,
				                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
				                     _("sum not 100%"));
				g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
				return FALSE;
			}
		} else {
			/* If the feature is disabled, sum must equal 0%, which was checked
			 * by the for() loop above.
			 */
			g_assert_cmpint (sum, ==, 0);
		}
	}

	return TRUE;
}

static gboolean
668
check_priority (int val,
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
                NMSettingDcbFlags flags,
                const char *prop_name,
                GError **error)
{
	if (!(flags & NM_SETTING_DCB_FLAG_ENABLE) && (val >= 0)) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
		                     _("property invalid (not enabled)"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
		return FALSE;
	}

	if (val < -1 || val > 7) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
		                     _("property invalid"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, prop_name);
		return FALSE;
	}
	return TRUE;
}

static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
	NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);

	if (!check_dcb_flags (priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_FLAGS, error))
		return FALSE;

	if (!check_priority (priv->app_fcoe_priority, priv->app_fcoe_flags, NM_SETTING_DCB_APP_FCOE_PRIORITY, error))
		return FALSE;

	if (!priv->app_fcoe_mode) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_MISSING_PROPERTY,
		                     _("property missing"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
		return FALSE;
	}

	if (strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_FABRIC) &&
	    strcmp (priv->app_fcoe_mode, NM_SETTING_DCB_FCOE_MODE_VN2VN)) {
		g_set_error_literal (error,
		                     NM_SETTING_DCB_ERROR,
		                     NM_SETTING_DCB_ERROR_INVALID_PROPERTY,
		                     _("property invalid"));
		g_prefix_error (error, "%s.%s: ", NM_SETTING_DCB_SETTING_NAME, NM_SETTING_DCB_APP_FCOE_MODE);
		return FALSE;
	}

	if (!check_dcb_flags (priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_FLAGS, error))
		return FALSE;

	if (!check_priority (priv->app_iscsi_priority, priv->app_iscsi_flags, NM_SETTING_DCB_APP_ISCSI_PRIORITY, error))
		return FALSE;

	if (!check_dcb_flags (priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_FLAGS, error))
		return FALSE;

	if (!check_priority (priv->app_fip_priority, priv->app_fip_flags, NM_SETTING_DCB_APP_FIP_PRIORITY, error))
		return FALSE;

	if (!check_dcb_flags (priv->pfc_flags, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, error))
		return FALSE;

	if (!check_uint_array (priv->pfc, G_N_ELEMENTS (priv->pfc), priv->pfc_flags, 1, 0, FALSE, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, error))
		return FALSE;

	if (!check_dcb_flags (priv->priority_group_flags, NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, error))
		return FALSE;

	if (!check_uint_array (priv->priority_group_id,
	                       G_N_ELEMENTS (priv->priority_group_id),
	                       priv->priority_group_flags,
	                       7,
	                       15,
	                       FALSE,
	                       NM_SETTING_DCB_PRIORITY_GROUP_ID,
	                       error))
		return FALSE;

	if (!check_uint_array (priv->priority_group_bandwidth,
	                       G_N_ELEMENTS (priv->priority_group_bandwidth),
	                       priv->priority_group_flags,
	                       100,
	                       0,
	                       TRUE,
	                       NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH,
	                       error))
		return FALSE;

	/* FIXME: sum bandwidths in each group */
	if (!check_uint_array (priv->priority_bandwidth,
	                       G_N_ELEMENTS (priv->priority_bandwidth),
	                       priv->priority_group_flags,
	                       100,
	                       0,
	                       FALSE,
	                       NM_SETTING_DCB_PRIORITY_BANDWIDTH,
	                       error))
		return FALSE;

	if (!check_uint_array (priv->priority_strict,
	                       G_N_ELEMENTS (priv->priority_strict),
	                       priv->priority_group_flags,
	                       1,
	                       0,
	                       FALSE,
	                       NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH,
	                       error))
		return FALSE;

	if (!check_uint_array (priv->priority_traffic_class,
	                       G_N_ELEMENTS (priv->priority_traffic_class),
	                       priv->priority_group_flags,
	                       7,
	                       0,
	                       FALSE,
	                       NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS,
	                       error))
		return FALSE;

	return TRUE;
}

798
/*****************************************************************************/
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833

static void
nm_setting_dcb_init (NMSettingDcb *setting)
{
}

static inline void
set_uint_array (const GValue *v, uint *a, size_t len)
{
	GArray *src = g_value_get_boxed (v);
	const guint total_len = len * sizeof (a[0]);

	memset (a, 0, total_len);
	if (src) {
		g_return_if_fail (g_array_get_element_size (src) == sizeof (a[0]));
		g_return_if_fail (src->len == len);
		memcpy (a, src->data, total_len);
	}
}
#define SET_UINT_ARRAY(v, a)  set_uint_array (v, a, G_N_ELEMENTS (a))

static void
set_property (GObject *object, guint prop_id,
              const GValue *value, GParamSpec *pspec)
{
	NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);

	switch (prop_id) {
	case PROP_APP_FCOE_FLAGS:
		priv->app_fcoe_flags = g_value_get_uint (value);
		break;
	case PROP_APP_FCOE_PRIORITY:
		priv->app_fcoe_priority = g_value_get_int (value);
		break;
	case PROP_APP_FCOE_MODE:
834
		g_free (priv->app_fcoe_mode);
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945
		priv->app_fcoe_mode = g_value_dup_string (value);
		break;
	case PROP_APP_ISCSI_FLAGS:
		priv->app_iscsi_flags = g_value_get_uint (value);
		break;
	case PROP_APP_ISCSI_PRIORITY:
		priv->app_iscsi_priority = g_value_get_int (value);
		break;
	case PROP_APP_FIP_FLAGS:
		priv->app_fip_flags = g_value_get_uint (value);
		break;
	case PROP_APP_FIP_PRIORITY:
		priv->app_fip_priority = g_value_get_int (value);
		break;
	case PROP_PFC_FLAGS:
		priv->pfc_flags = g_value_get_uint (value);
		break;
	case PROP_PFC:
		SET_UINT_ARRAY (value, priv->pfc);
		break;
	case PROP_PRIORITY_GROUP_FLAGS:
		priv->priority_group_flags = g_value_get_uint (value);
		break;
	case PROP_PRIORITY_GROUP_ID:
		SET_UINT_ARRAY (value, priv->priority_group_id);
		break;
	case PROP_PRIORITY_GROUP_BANDWIDTH:
		SET_UINT_ARRAY (value, priv->priority_group_bandwidth);
		break;
	case PROP_PRIORITY_BANDWIDTH:
		SET_UINT_ARRAY (value, priv->priority_bandwidth);
		break;
	case PROP_PRIORITY_STRICT:
		SET_UINT_ARRAY (value, priv->priority_strict);
		break;
	case PROP_PRIORITY_TRAFFIC_CLASS:
		SET_UINT_ARRAY (value, priv->priority_traffic_class);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

#define TAKE_UINT_ARRAY(v, a) \
{ \
	guint len = G_N_ELEMENTS (a); \
	GArray *dst = g_array_sized_new (FALSE, TRUE, sizeof (guint), len); \
	g_array_append_vals (dst, (a), len); \
	g_value_take_boxed (v, dst); \
}

static void
get_property (GObject *object, guint prop_id,
              GValue *value, GParamSpec *pspec)
{
	NMSettingDcb *setting = NM_SETTING_DCB (object);
	NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (setting);

	switch (prop_id) {
	case PROP_APP_FCOE_FLAGS:
		g_value_set_uint (value, priv->app_fcoe_flags);
		break;
	case PROP_APP_FCOE_PRIORITY:
		g_value_set_int (value, priv->app_fcoe_priority);
		break;
	case PROP_APP_FCOE_MODE:
		g_value_set_string (value, priv->app_fcoe_mode);
		break;
	case PROP_APP_ISCSI_FLAGS:
		g_value_set_uint (value, priv->app_iscsi_flags);
		break;
	case PROP_APP_ISCSI_PRIORITY:
		g_value_set_int (value, priv->app_iscsi_priority);
		break;
	case PROP_APP_FIP_FLAGS:
		g_value_set_uint (value, priv->app_fip_flags);
		break;
	case PROP_APP_FIP_PRIORITY:
		g_value_set_int (value, priv->app_fip_priority);
		break;
	case PROP_PFC_FLAGS:
		g_value_set_uint (value, priv->pfc_flags);
		break;
	case PROP_PFC:
		TAKE_UINT_ARRAY (value, priv->pfc);
		break;
	case PROP_PRIORITY_GROUP_FLAGS:
		g_value_set_uint (value, priv->priority_group_flags);
		break;
	case PROP_PRIORITY_GROUP_ID:
		TAKE_UINT_ARRAY (value, priv->priority_group_id);
		break;
	case PROP_PRIORITY_GROUP_BANDWIDTH:
		TAKE_UINT_ARRAY (value, priv->priority_group_bandwidth);
		break;
	case PROP_PRIORITY_BANDWIDTH:
		TAKE_UINT_ARRAY (value, priv->priority_bandwidth);
		break;
	case PROP_PRIORITY_STRICT:
		TAKE_UINT_ARRAY (value, priv->priority_strict);
		break;
	case PROP_PRIORITY_TRAFFIC_CLASS:
		TAKE_UINT_ARRAY (value, priv->priority_traffic_class);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}

946 947 948 949 950 951 952 953 954 955
static void
finalize (GObject *object)
{
	NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE (object);

	g_free (priv->app_fcoe_mode);

	G_OBJECT_CLASS (nm_setting_dcb_parent_class)->finalize (object);
}

956 957 958 959 960 961 962 963 964 965 966
static void
nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
{
	GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
	NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);

	g_type_class_add_private (setting_class, sizeof (NMSettingDcbPrivate));

	/* virtual methods */
	object_class->set_property = set_property;
	object_class->get_property = get_property;
967
	object_class->finalize = finalize;
968 969 970 971 972 973
	parent_class->verify       = verify;

	/* Properties */
	/**
	 * NMSettingDcb:app-fcoe-flags:
	 *
974 975 976
	 * Specifies the #NMSettingDcbFlags for the DCB FCoE application.  Flags may
	 * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
	 * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
977 978 979 980 981
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_FCOE_FLAGS,
982
		 g_param_spec_uint (NM_SETTING_DCB_APP_FCOE_FLAGS, "", "",
983
		                    0, DCB_FLAGS_ALL, 0,
984 985
		                    G_PARAM_READWRITE |
		                    G_PARAM_STATIC_STRINGS));
986 987 988 989 990

	/**
	 * NMSettingDcb:app-fcoe-priority:
	 *
	 * The highest User Priority (0 - 7) which FCoE frames should use, or -1 for
991 992
	 * default priority.  Only used when the #NMSettingDcb:app-fcoe-flags
	 * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
993 994 995 996 997
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_FCOE_PRIORITY,
998
		 g_param_spec_int (NM_SETTING_DCB_APP_FCOE_PRIORITY, "", "",
999
		                   -1, 7, -1,
1000 1001
		                   G_PARAM_READWRITE |
		                   G_PARAM_CONSTRUCT |
1002
		                   G_PARAM_STATIC_STRINGS));
1003 1004 1005 1006

	/**
	 * NMSettingDcb:app-fcoe-mode:
	 *
1007 1008
	 * The FCoE controller mode; either %NM_SETTING_DCB_FCOE_MODE_FABRIC
	 * (default) or %NM_SETTING_DCB_FCOE_MODE_VN2VN.
1009 1010 1011 1012 1013
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_FCOE_MODE,
1014
		 g_param_spec_string (NM_SETTING_DCB_APP_FCOE_MODE, "", "",
1015
		                      NM_SETTING_DCB_FCOE_MODE_FABRIC,
1016 1017
		                      G_PARAM_READWRITE |
		                      G_PARAM_CONSTRUCT |
1018
		                      G_PARAM_STATIC_STRINGS));
1019 1020 1021 1022

	/**
	 * NMSettingDcb:app-iscsi-flags:
	 *
1023 1024 1025
	 * Specifies the #NMSettingDcbFlags for the DCB iSCSI application.  Flags
	 * may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
	 * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1026 1027 1028 1029 1030
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_ISCSI_FLAGS,
1031
		 g_param_spec_uint (NM_SETTING_DCB_APP_ISCSI_FLAGS, "", "",
1032
		                    0, DCB_FLAGS_ALL, 0,
1033 1034
		                    G_PARAM_READWRITE |
		                    G_PARAM_STATIC_STRINGS));
1035 1036 1037 1038

	/**
	 * NMSettingDcb:app-iscsi-priority:
	 *
1039 1040 1041
	 * The highest User Priority (0 - 7) which iSCSI frames should use, or -1
	 * for default priority. Only used when the #NMSettingDcb:app-iscsi-flags
	 * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
1042 1043 1044 1045 1046
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_ISCSI_PRIORITY,
1047
		 g_param_spec_int (NM_SETTING_DCB_APP_ISCSI_PRIORITY, "", "",
1048
		                   -1, 7, -1,
1049 1050
		                   G_PARAM_READWRITE |
		                   G_PARAM_CONSTRUCT |
1051
		                   G_PARAM_STATIC_STRINGS));
1052 1053 1054 1055

	/**
	 * NMSettingDcb:app-fip-flags:
	 *
1056 1057 1058
	 * Specifies the #NMSettingDcbFlags for the DCB FIP application.  Flags may
	 * be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
	 * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1059 1060 1061 1062 1063
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_FIP_FLAGS,
1064
		 g_param_spec_uint (NM_SETTING_DCB_APP_FIP_FLAGS, "", "",
1065
		                    0, DCB_FLAGS_ALL, 0,
1066 1067
		                    G_PARAM_READWRITE |
		                    G_PARAM_STATIC_STRINGS));
1068 1069 1070 1071

	/**
	 * NMSettingDcb:app-fip-priority:
	 *
1072 1073 1074
	 * The highest User Priority (0 - 7) which FIP frames should use, or -1 for
	 * default priority.  Only used when the #NMSettingDcb:app-fip-flags
	 * property includes the %NM_SETTING_DCB_FLAG_ENABLE flag.
1075 1076 1077 1078 1079
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_APP_FIP_PRIORITY,
1080
		 g_param_spec_int (NM_SETTING_DCB_APP_FIP_PRIORITY, "", "",
1081
		                   -1, 7, -1,
1082 1083
		                   G_PARAM_READWRITE |
		                   G_PARAM_CONSTRUCT |
1084
		                   G_PARAM_STATIC_STRINGS));
1085 1086 1087 1088

	/**
	 * NMSettingDcb:priority-flow-control-flags:
	 *
1089
	 * Specifies the #NMSettingDcbFlags for DCB Priority Flow Control (PFC).
1090 1091
	 * Flags may be any combination of %NM_SETTING_DCB_FLAG_ENABLE,
	 * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1092 1093 1094 1095 1096
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PFC_FLAGS,
1097
		 g_param_spec_uint (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, "", "",
1098
		                    0, DCB_FLAGS_ALL, 0,
1099 1100
		                    G_PARAM_READWRITE |
		                    G_PARAM_STATIC_STRINGS));
1101 1102 1103 1104

	/**
	 * NMSettingDcb:priority-flow-control:
	 *
1105 1106 1107 1108
	 * An array of 8 uint values, where the array index corresponds to the User
	 * Priority (0 - 7) and the value indicates whether or not the corresponding
	 * priority should transmit priority pause.  Allowed values are 0 (do not
	 * transmit pause) and 1 (transmit pause).
1109 1110 1111 1112 1113
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PFC,
1114
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, "", "",
1115
		                             DBUS_TYPE_G_UINT_ARRAY,
1116 1117
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1118 1119 1120 1121

	/**
	 * NMSettingDcb:priority-group-flags:
	 *
1122 1123 1124
	 * Specifies the #NMSettingDcbFlags for DCB Priority Groups.  Flags may be
	 * any combination of %NM_SETTING_DCB_FLAG_ENABLE,
	 * %NM_SETTING_DCB_FLAG_ADVERTISE, and %NM_SETTING_DCB_FLAG_WILLING.
1125 1126 1127 1128 1129
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_GROUP_FLAGS,
1130
		 g_param_spec_uint (NM_SETTING_DCB_PRIORITY_GROUP_FLAGS, "", "",
1131
		                    0, DCB_FLAGS_ALL, 0,
1132 1133
		                    G_PARAM_READWRITE |
		                    G_PARAM_STATIC_STRINGS));
1134 1135 1136 1137

	/**
	 * NMSettingDcb:priority-group-id:
	 *
1138 1139 1140
	 * An array of 8 uint values, where the array index corresponds to the User
	 * Priority (0 - 7) and the value indicates the Priority Group ID.  Allowed
	 * Priority Group ID values are 0 - 7 or 15 for the unrestricted group.
1141 1142 1143 1144 1145
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_GROUP_ID,
1146
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_ID, "", "",
1147
		                             DBUS_TYPE_G_UINT_ARRAY,
1148 1149
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1150 1151 1152 1153 1154

	/**
	 * NMSettingDcb:priority-group-bandwidth:
	 *
	 * An array of 8 uint values, where the array index corresponds to the
1155 1156
	 * Priority Group ID (0 - 7) and the value indicates the percentage of link
	 * bandwidth allocated to that group.  Allowed values are 0 - 100, and the
1157
	 * sum of all values must total 100 percents.
1158 1159 1160 1161 1162
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_GROUP_BANDWIDTH,
1163
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, "", "",
1164
		                             DBUS_TYPE_G_UINT_ARRAY,
1165 1166
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1167 1168 1169 1170

	/**
	 * NMSettingDcb:priority-bandwidth:
	 *
1171 1172 1173 1174
	 * An array of 8 uint values, where the array index corresponds to the User
	 * Priority (0 - 7) and the value indicates the percentage of bandwidth of
	 * the priority's assigned group that the priority may use.  The sum of all
	 * percentages for priorities which belong to the same group must total 100
1175
	 * percents.
1176 1177 1178 1179 1180
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_BANDWIDTH,
1181
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_BANDWIDTH, "", "",
1182
		                             DBUS_TYPE_G_UINT_ARRAY,
1183 1184
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1185 1186

	/**
1187
	 * NMSettingDcb:priority-strict-bandwidth:
1188
	 *
1189 1190 1191 1192 1193
	 * An array of 8 uint values, where the array index corresponds to the User
	 * Priority (0 - 7) and the value indicates whether or not the priority may
	 * use all of the bandwidth allocated to its assigned group.  Allowed values
	 * are 0 (the priority may not utilize all bandwidth) or 1 (the priority may
	 * utilize all bandwidth).
1194 1195 1196 1197 1198
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_STRICT,
1199
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, "", "",
1200
		                             DBUS_TYPE_G_UINT_ARRAY,
1201 1202
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1203 1204 1205 1206

	/**
	 * NMSettingDcb:priority-traffic-class:
	 *
1207 1208 1209
	 * An array of 8 uint values, where the array index corresponds to the User
	 * Priority (0 - 7) and the value indicates the traffic class (0 - 7) to
	 * which the priority is mapped.
1210 1211 1212 1213 1214
	 *
	 * Since: 0.9.10
	 **/
	g_object_class_install_property
		(object_class, PROP_PRIORITY_TRAFFIC_CLASS,
1215
		 _nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, "", "",
1216
		                             DBUS_TYPE_G_UINT_ARRAY,
1217 1218
		                             G_PARAM_READWRITE |
		                             G_PARAM_STATIC_STRINGS));
1219
}